﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BaiTu.QueueEntity;

namespace BaiTu.IQueueService
{
    /// <summary>
    /// 队列服务接口
    /// </summary>
    public interface IQueue
    {
        /// <summary>
        /// 如果队列不存在 则创建队列
        /// </summary>
        void CreateIfNotExists<T>();
        /// <summary>
        /// 客户端发送请求  发送消息第一步
        /// </summary>
        string SendRequestToWorker<T>(Message<T> message);
        /// <summary>
        /// 
        /// </summary>
        string SendRequestToWorker<T>(T message, string messageID = null);
        /// <summary>
        /// 后端worker 接收请求  第二步
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        Message<T> GetRequestFromClient<T>();
        /// <summary>
        /// 后端worker 发送处理回复结果 第三步
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="message"></param>
        /// <param name="requestMessageID"></param>
        void SendResponseToClient<T>(T message, string requestMessageID);
        /// <summary>
        /// 客户端接收到workder的回复消息  第四步
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="requestMessageID"></param>
        /// <returns></returns>
        T GetResponseFromWorker<T>(string requestMessageID);
    }
}
